package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

	@Reference
	private StatService statService;

	/**
	 * 进入统计页面
	 *  参数：chartsType （factory，online，sell）
	 */
	@RequestMapping("/toCharts")
	public String toCharts(String chartsType) {
		return "stat/stat-"+chartsType;
	}

	/**
	 * 通过ajax的请求请求，获取厂家的销量统计,返回json
	 */
	@RequestMapping("/findFactoryData")
	public @ResponseBody List findFactoryData() {
		return statService.findFactoryData(getLoginCompanyId());
	}

	/**
	 * 通过ajax的请求,获取产品的销售排行榜，返回json
	 */
	@RequestMapping("/findSellData")
	public @ResponseBody List findSellData() {
		return statService.findSellData(getLoginCompanyId());
	}

	/**
	 * 通过ajax的请求,获取系统访问压力图数据，返回json
	 */
	@RequestMapping("/findOnlineData")
	public @ResponseBody List findOnlineData() {
		return statService.findOnlineData(getLoginCompanyId());
	}

	//通过ajax请求,获取市场价最高的前10名产品,返回json
	@RequestMapping("/findCargoData")
	public @ResponseBody List findCargoData(){
		return statService.findCargoData(getLoginCompanyId());
	}

	//通过ajax请求,获取ip登录次数最多的用户,返回json
	@RequestMapping("/findIpData")
	public @ResponseBody List findIpData(){
		return statService.findIpData(getLoginCompanyId());
	}
}
